//
//  BackBoxManagerVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/28.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "BackBoxManagerVC.h"
#import "BackBoxListVC.h"
#import "BackBoxEditVC.h"

@interface BackBoxManagerVC ()<ZJScrollPageViewDelegate>

@property (nonatomic, strong) ZJSegmentStyle *menuStyle;//菜单栏
@property (nonatomic, strong) NSArray<NSString *> *titles;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;
@property (nonatomic, strong) UIView *scrollPageBGView;
@property (nonatomic, strong) UIView *bottomView;

@end

@implementation BackBoxManagerVC

-(UIView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenH - BottomHeight - NaviHeight - 64, ScreenW, 64+BottomHeight)];
        _bottomView.backgroundColor = HexColor(0xffffff);
        UIButton *editBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 10, ScreenW - 30, 44)];
        [editBtn setBackgroundColor:HexColorA(0x3D68EB, 0.1)];
        editBtn.layer.masksToBounds = YES;
        editBtn.layer.cornerRadius = 6;
        [editBtn setTitle:@"设置空置" forState:0];
        [editBtn setTitleColor:Color_ThemeColor forState:0];
        editBtn.titleLabel.font = BoldFontOfSize(16);
        [editBtn addTarget:self action:@selector(setClick) forControlEvents:UIControlEventTouchUpInside];
        [_bottomView addSubview:editBtn];
    }
    return _bottomView;
}

- (void)setClick {
    BackBoxEditVC *vc = [BackBoxEditVC new];
    [self.rt_navigationController pushViewController:vc animated:YES];
}

-(ZJScrollPageView *)scrollPageView {
    if (!_scrollPageView) {
        _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH - BottomHeight - 64 - NaviHeight) segmentStyle:self.menuStyle titles:self.titles parentViewController:self delegate:self];
    }
    return _scrollPageView;
}

-(UIView *)scrollPageBGView {
    if (!_scrollPageBGView) {
        _scrollPageBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 40)];
        _scrollPageBGView.backgroundColor = [UIColor whiteColor];
    }
    return _scrollPageBGView;
}

-(ZJSegmentStyle *)menuStyle {
    if (!_menuStyle) {
        _menuStyle = [ZJSegmentStyle new];
        _menuStyle.autoAdjustTitlesWidth = YES;
        _menuStyle.showLine = YES;//显示下划线
        _menuStyle.scrollTitle = YES;//设置标题栏可以滚动
        _menuStyle.segmentViewBounces = YES;//设置滚动标题栏有弹性
        _menuStyle.scaleTitle = YES;//设置选中标题缩放
        _menuStyle.scrollContentView = YES;//内容可以滑动
        _menuStyle.normalTitleColor = HexColor(0x9C9DB3);
        _menuStyle.selectedTitleColor = Color_ThemeColor;
        _menuStyle.scrollLineColor = Color_ThemeColor;
        _menuStyle.scrollLineWidth = 12;
        _menuStyle.segmentHeight = 40;
        _menuStyle.titleBigScale = 1.1;
        _menuStyle.titleFont = [UIFont systemFontOfSize:14];
    }
    return _menuStyle;
}

-(NSArray<NSString *> *)titles {
    if (!_titles) {
        _titles = @[@"全部",@"使用中",@"空置",@"待回收"];
    }
    return _titles;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"返箱管理";
    [self.view addSubview:self.scrollPageBGView];
    [self.view addSubview:self.scrollPageView];
    [self.view addSubview:self.bottomView];
}

- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    BackBoxListVC<ZJScrollPageViewChildVcDelegate> * childVC = (BackBoxListVC *)reuseViewController;
    BackBoxListVC *vc = [BackBoxListVC new];
//    vc.type = index;
    childVC = vc;
    return childVC;
}

//子控制器实现完整生命周期
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
